<?php

/**
 * Menashop
 *
 * LICENSE
 *
 * This source file is subject to the license that is bundled
 * with this project in the file LICENSE.txt
 *
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FormDistributor
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 * @version    1.0.0
 * @since      File available since Release 1.0.0
 */

/**
 * The form for distributor
 * 
 * @category   Zend
 * @package    Admin_Model
 * @subpackage FromDistributor
 * @copyright  Copyright (c) 2011 Menashop UA Inc. (http://www.menashop.com.ua)
 * @license    LICENSE.txt
 */
class Admin_Model_FormDistributor extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');

        $id = new Zend_Form_Element_Hidden('id');
        $id->removeDecorator('label');
        $id->removeDecorator('htmlTag');
        $this->addElement($id);

        $name = new Zend_Form_Element_Text('name');
        $name->setRequired(true);
        $name->addValidator('StringLength', false, array(2, 50));
        $name->addErrorMessage('Please provide correct name');
        $name->removeDecorator('label');
        $name->removeDecorator('htmlTag');
        $name->removeDecorator('Errors');
        $this->addElement($name);

        $manager = new Zend_Form_Element_Text('manager');
        $manager->addValidator('StringLength', false, array(2, 50));
        $manager->addErrorMessage('Please provide correct manager name');
        $manager->removeDecorator('label');
        $manager->removeDecorator('htmlTag');
        $manager->removeDecorator('Errors');
        $this->addElement($manager);

        $email = new Zend_Form_Element_Text('email');
        $email->addValidator('EmailAddress');
        $email->addErrorMessage('Please provide a correct e-mail');
        $email->removeDecorator('label');
        $email->removeDecorator('htmlTag');
        $email->removeDecorator('Errors');
        $this->addElement($email);

        $phone = new Zend_Form_Element_Text('phone');
        $phone->addValidator('StringLength', false, array(2, 50));
        $phone->addErrorMessage('Please provide correct phone');
        $phone->removeDecorator('label');
        $phone->removeDecorator('htmlTag');
        $phone->removeDecorator('Errors');
        $this->addElement($phone);

        $currency = new Zend_Form_Element_Select('currency');
        $currencyModel = new Admin_Model_Currency();
        $currencies = $currencyModel->fetchAllPairs();
        foreach ($currencies as $key => $value) {
            $currency->addMultiOption($key, $value);
        }
        $currency->removeDecorator('label');
        $currency->removeDecorator('htmlTag');
        $currency->removeDecorator('Errors');
        $this->addElement($currency);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->removeDecorator('DtDdWrapper');
        $this->addElement($submit);

        $this->setDecorators(array(array('ViewScript', array('viewScript' => '_form_distributor.phtml'))));
    }

}

